package com.itheima.spring.spring;

import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

import java.beans.PropertyDescriptor;

/**
 * @author ：sean
 * @date ：Created in 2020/6/28
 * @description ：
 * @version: 1.0
 */
@Component
public class HeimaInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		if("userServiceImpl".equals(beanName)){
			System.out.println("userServiceImpl HeimaInstantiationAwareBeanPostProcessor postProcessBeforeInstantiation...");
		}
		return null;
	}

	@Override
	public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
		if("userServiceImpl".equals(beanName)){
			System.out.println("userServiceImpl HeimaInstantiationAwareBeanPostProcessor postProcessAfterInstantiation...");
		}
		return true;
	}

	@Override
	public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
		if("userServiceImpl".equals(beanName)){
			System.out.println("userServiceImpl HeimaInstantiationAwareBeanPostProcessor postProcessPropertyValues...");
		}
		return pvs;
	}
}
